<?php
include_once '../../Config/config.php';
include_once '../../Config/conexion.php';
include_once '../../Model/Paper.php';

include_once '../../Model/Track.php';
include_once '../../Model/Idioma.php';
?>
	<table class="tabla-basica">	
	<thead>
	<tr>
        <th>
			#
		</th>
		<th>
			Paper
		</th>
		<th>
			Revisor
		</th>		
		<th>
			Autor
		</th>	
		<th>
			Papers y Abstract
		</th>		
<!--		<th>
			Doc. Evaluaci&oacute;n/
			Resultado Final
		</th>-->
		<th>
			Paper Final
		</th>
		<th>
			Fecha
		</th>
		<th></th>
        <th></th>
        </tr>
	</thead>
	<tbody>
		<?php
			
			$revisorPost	=(isset($_POST["revisor_id"])&& $_POST["revisor_id"]!="0")?$_POST["revisor_id"]:"";

			$track_id = (isset($_POST["track_id"])&& $_POST["track_id"]!="0")?$_POST["track_id"]:"";			
			$idioma_id = (isset($_POST["idioma_id"])&& $_POST["idioma_id"]!=0)?$_POST["idioma_id"]:"";
			$estado = (isset($_POST["estado"])&& $_POST["estado"]!=0)?$_POST["estado"]:"";
			$anio = (isset($_POST["anio"])&& $_POST["anio"]!=0)?$_POST["anio"]:"";
			
			$lista = Paper::Listar($track_id, $idioma_id, $estado, $anio);
			
			$i = 0;
				$a=0;
				foreach($lista as $key => $value){
				/*$a=0;
				if(isset($value->revisores)){
					foreach($value->revisores as $revisor){
						 if($revisor->revisor_id==$revisorPost){
						 	$a=1;
						 }
					}
				}*/

				if($a==1||$revisorPost=="0"||$revisorPost==""){	
			?>
            	<tr class="row<?php echo ($i++)%2; ?>">
                <td>
					<p><?php echo htmlentities(utf8_decode($value->Titulo))?></p>
	                <p style="font-style:italic;font-size:11px;color:#666"><?php echo $value->Track->Nombre?></p>
    	            <p style="font-style:italic;font-size:11px;color:#666"><?php echo $value->Idioma->Nombre?></p> 				                    
                </td>
                <td>
					Revisores
					<ul>
					<?php
						foreach($value->Revisores as $revisor){
					?>
						<ol>
							<?php 
								echo Util::FormatoHtml($revisor->Nombres)." ".Util::FormatoHtml($revisor->Paterno);
							?>
						</ol>
					<?php
						}						
					?>
					</ul>
                </td>
                <td>
					<ul class="list-autores">
					<?php
						//print_r($value->Autores);											
						foreach($value->Autores as $autor){
					?>						
							<li><?php echo Util::FormatoHtml($autor->Nombres)?> <?php echo Util::FormatoHtml($autor->Paterno)?> <?php echo Util::FormatoHtml($autor->Materno)?></li>						
					<?php
						}
					?>
					</ul>
				</td>			
               			

                <td>
                         
							<a href="<?php echo  INI_URL?>/files/papers/<?php echo $value->PaperFile?>">
								<img src="<?php echo INI_URL?>/Content/template01/images/paper.png ">Paper
							</a>
                         
						<br />
							<a href="<?php echo INI_URL?>/files/abstract/<?php echo $value->PaperAbstract?>">
								<img src="<?php echo INI_URL?>/Content/template01/images/abstract.png ">Abstract
							</a>

                </td>
                <!--<td></td>-->
                <td>
                    <?php if($value->PaperFinal != ""){?>
                        <img src="<?php echo INI_URL?>/Content/template01/images/paper.png "><a href="<?php echo INI_URL?>/files/papers_final/<?php echo $value->PaperFinal;?>">Paper</a>
                    <?php }?>
                </td>
                <td>
                <?php echo $value->FechaSubida?>
                </td>
                <td>
					
                    <?php if($value->esAnonimo){?>
                    <a class="asignarrevisor" data-id="<?php echo $value->IdPaper?>">Asignar Revisor</a>
                    <?php }else{ ?>
                    <a class="anonimato" data-id="<?php echo $value->IdPaper?>">Es An&oacute;nimo?</a>
                    <?php } ?>
                </td>
                <td>
                    <a href="#" class="eliminarPaper" data-idpaper="<?php echo $value->IdPaper;?>">
                        <img src="<?php echo INI_URL?>/Content/template01/images/trash1.png" />
                    </a>
                </td>
            </tr>			
		<?php
				}			
		}
		?>
	</tbody>
	</table>
<div id="revisor-formu-revisar"></div>